package com.example.demo.service.serviceImpl;

import com.example.demo.entity.Author;
import com.example.demo.mapper.AuthorMapper;
import com.example.demo.service.AuthorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 作者基本信息表(Author)Service层
 *
 * @author makejava
 * @since 2021-02-26 15:38:46
 */
@Service
 @Transactional(rollbackFor = {RuntimeException.class, Exception.class})
public class AuthorServiceImpl implements AuthorService {
        @Autowired
        private AuthorMapper authorMapper;


 /**
     * 通过ID和其他条件查询单条数据
     *
     * @param author 实例对象
     * @return 实例对象
     */
       @Override
 @Transactional(rollbackFor = {RuntimeException.class, Exception.class})
     public Author queryAuthorLimit1(Author author){
     return  authorMapper.queryAuthorLimit1( author);
     }
     
 /**
     * 查询指定行数据
     * @param author 实例对象
     * @param offset 查询起始位置
     * @param limit 查询条数
     * @return 对象列表
     */
       @Override
 @Transactional(rollbackFor = {RuntimeException.class, Exception.class})
  public   List<Author> queryAllAuthorByLimit( Author author, Integer offset,  Integer limit){
   return authorMapper.queryAllAuthorByLimit(author, offset,limit);
  }

  /**
     * 查询数据条数
     * @return 条数
     */
       @Override
 @Transactional(rollbackFor = {RuntimeException.class, Exception.class})
   public int countAllAuthor(Author author){
   return authorMapper.countAllAuthor( author);
   }
   /**
     * 通过实体作为筛选条件查询
     *
     * @param author 实例对象
     * @return 对象列表
     */
       @Override
 @Transactional(rollbackFor = {RuntimeException.class, Exception.class})
   public List<Author> queryAllAuthor(Author author){
   return authorMapper.queryAllAuthor(author);
   }
  /**
     * 新增数据
     *
     * @param author 实例对象
     * @return 影响行数
     */
     @Override
   @Transactional(rollbackFor = {RuntimeException.class, Exception.class})
    public int insertAuthor(Author author){
    return  authorMapper.insertAuthor( author);
    }
  /**
     * 修改数据
     *
     * @param author 实例对象
     * @return 影响行数
     */
       @Override
 @Transactional(rollbackFor = {RuntimeException.class, Exception.class})
     public  int updateAuthor(Author author){
         return authorMapper.updateAuthor( author);
     }

    /**
     * 通过主键删除数据
     * @param authorId 主键
     * @return 影响行数
     */
      @Override
  @Transactional(rollbackFor = {RuntimeException.class, Exception.class})
   public  int deleteAuthorById(String authorId){
   return  authorMapper.deleteAuthorById( authorId);
   }
     /**
     * 通过主键列表删除，列表长度不能为0
     * @param list 集合
     * @return 条数
     */
      @Override
  @Transactional(rollbackFor = {RuntimeException.class, Exception.class})
  public  int deleteAuthorByIds( List<String> list){
    return  authorMapper.deleteAuthorByIds(  list);
  }
    
       /**
     * 通过主键修改实体列表，列表长度不能为0，注意：当实体属性为null时，对应的列也会别更新为null
     * @param list 集合
     * @return 条数
     */
       @Override
 @Transactional(rollbackFor = {RuntimeException.class, Exception.class})
   public int updateAuthorBatch( List<Author> list){
   return  authorMapper.updateAuthorBatch(list);
   }
    /**
     * 批量其他列,除主键以外的列，列表长度不能为0,字段是空的就置为null
     * @param list 集合
     * @return 条数
     */
      @Override
  @Transactional(rollbackFor = {RuntimeException.class, Exception.class})
 public   int insertAuthorBatch( List<Author> list){
 return authorMapper.insertAuthorBatch( list);
 }
      /**
     * 通过实体非空属性删除
     * @param author  实体
     * @return 条数
     */
        @Override
@Transactional(rollbackFor = {RuntimeException.class, Exception.class})
  public   int deleteAuthorByEntity( Author author){
  return  authorMapper.deleteAuthorByEntity(  author);
  }
    /**
     * 通过实体不为空的属性作为筛选条件查询列表
     * @param author  实体
     * @return list
     */
       @Override
 @Transactional(rollbackFor = {RuntimeException.class, Exception.class})
   public  List<Author> listAuthorByEntity(Author author){
   return authorMapper.listAuthorByEntity( author);
   }

 /**
     * 新增实体属性不为null的列
     * @param author  实体
     * @return 条数
     */
       @Override
 @Transactional(rollbackFor = {RuntimeException.class, Exception.class})
   public  int insertAuthorSelect( Author author){
      return authorMapper.insertAuthorSelect( author);

   }
   
      /**
     * 批量新增新增实体属性不为null的列
     * @param list  实体
     * @return 条数
     */
        @Override
@Transactional(rollbackFor = {RuntimeException.class, Exception.class})
  public  int insertAuthorListSelect( List<Author> list){

     return authorMapper.insertAuthorListSelect( list);
      }
     /**
     * 通过实体不为空的属性作为筛选条件查询单个
     * @param author  实体
     * @return 单个
     */
     @Override
   @Transactional(rollbackFor = {RuntimeException.class, Exception.class})
    public  Author getAuthorByEntity(Author author){
     return  authorMapper.getAuthorByEntity(author);
    }

}

